/*
 * @Descripttion:
 * @Author: wayde
 * @Date: 2021-05-13 20:05:25
 */
class queue {
  constructor() {
    this.count = 0;
    this.list = {};
    this.lowestCount = 0;
  }
  // 入队
  enqueue(element) {
    this.list[this.count] = element;
    this.count++;
  }
  isEmpty() {
    return this.count - this.lowestCount === 0;
  }
  // 出队先进先出
  dequeue() {
    if (this.isEmpty()) {
      return undefined;
    }
    const result = this.list[this.lowestCount];
    delete this.list[this.lowestCount];
    this.lowestCount++;
    return result;
  }
  size() {
    return this.count - this.lowestCount;
  }
  //查看队列头元素
  peek() {
    if (this.isEmpty()) {
      return undefined;
    }
    return this.list[this.lowestCount];
  }
  //清空队列
  clear() {
    this.list = {};
    this.count = 0;
    this.lowestCount = 0;
  }
  //字符串方法
  toString() {
    if (this.isEmpty()) {
      return "";
    }
    let str = `${this.list[this.lowestCount]}`;
    for (let i = this.lowestCount + 1; i < this.count; i++) {
      str += `,${this.list[i]}`;
    }
    return str;
  }
}
全排列